<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Support\Facades\Redis;

class Login
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {

        # 判断用户是否登录 根据自己存储方式来判断
//        session('mobile')
        $mobile = Redis::hget('userInfo','mobile');
        if (empty($mobile)) {
            # 未登录、跳转到登录页面
            return  redirect('/blog/login');
        }

        return $next($request);
    }
}
